package com.sun.hunk.hibernate.domain.impl;

import com.sun.hunk.hibernate.domain.CodeType;
import com.sun.hunk.hibernate.domain.GenericCodeLabel;
import com.sun.hunk.hibernate.domain.GenericCodeValue;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author sunil
 */
@Entity
@Table(name = "generic_code_label")
public class GenericCodeLabelImpl implements GenericCodeLabel {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "label")
    private String label;
    @Column(name = "input_type")
    private String inputType;
    @JoinColumn(name = "code_type_id", referencedColumnName = "id")
    @ManyToOne(optional = false,targetEntity=CodeTypeImpl.class)
    private CodeType codeType;
    @OneToMany(mappedBy = "genericCodeLabel",targetEntity=GenericCodeValueImpl.class)
    private Set<GenericCodeValue> genericCodeValueSet;

    public GenericCodeLabelImpl() {
    }

    public GenericCodeLabelImpl(Long id) {
        this.id = id;
    }

    public GenericCodeLabelImpl(Long id, String label) {
        this.id = id;
        this.label = label;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getInputType() {
        return inputType;
    }

    public void setInputType(String inputType) {
        this.inputType = inputType;
    }

    public CodeType getCodeType() {
        return codeType;
    }

    public void setCodeType(CodeType codeType) {
        this.codeType = codeType;
    }

    public Set<GenericCodeValue> getGenericCodeValueSet() {
        return genericCodeValueSet;
    }

    public void setGenericCodeValueSet(Set<GenericCodeValue> genericCodeValueSet) {
        this.genericCodeValueSet = genericCodeValueSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GenericCodeLabelImpl)) {
            return false;
        }
        GenericCodeLabelImpl other = (GenericCodeLabelImpl) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.cong.logiware.hibernate.domain.GenericCodeLabel[id=" + id + "]";
    }

}
